<template>
	<view class="info-body">
		<view class="uni-box-head">
			<uni-title type="h1" align="center" :title="form.title"></uni-title>
		</view>
		<view class="uni-info">
			<text class="uni-info-text">{{form.name}}</text>
			<text class="uni-info-text">{{form.time}}</text>
		</view>
		<scroll-view scroll-y="true" class="sv" :style="{height:navHeight+'px'}">
			<view class="uni-info-content">
				<text >
				</text>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pH: 0, //窗口高度
				navHeight: 0, //元素的所需高度
				id: null,
				form: {
					name: "sdfasdf",
					time: "sdfwew"
				},
			}
		},
		methods: {
			//数据请求
			getInforData() {
				getInfor(this.id).then(res => {
					this.form = res.data;
					let sefe = this;
					setTimeout(function() {
						//延时调用
						sefe.setLayout()
					}, 500)
				})
			},
			//设置内容高度
			setLayout() {
				let that = this;
				uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
					success(res) { //成功回调函数
						that._data.pH = res.windowHeight //windoHeight为窗口高度，主要使用的是这个
						let titleH = uni.createSelectorQuery().select(".sv"); //想要获取高度的元素名（class/id）
						titleH.boundingClientRect(data => {
							let pH = that._data.pH;
							that._data.navHeight = pH - data.top //计算高度：元素高度=窗口高度-元素距离顶部的距离（data.top）
							console.log(pH, that._data.navHeight, data.top)
						}).exec()
					}
				})
			},
		},
		onReady() {
			let that = this;
			uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
				success(res) { //成功回调函数
					that._data.pH = res.windowHeight //windoHeight为窗口高度，主要使用的是这个
					let titleH = uni.createSelectorQuery().select(".sv"); //想要获取高度的元素名（class/id）
					titleH.boundingClientRect(data => {
						let pH = that._data.pH;
						that._data.navHeight = pH - data.top //计算高度：元素高度=窗口高度-元素距离顶部的距离（data.top）
					}).exec()
				}
			})
		},
	}
</script>

<style>
	.uni-info-content {
		overflow-y: auto;
		height: 80vh;
	}
</style>